defmodule LetcodirTest do
	use ExUnit.Case
	doctest Letcodir

	test "Letcodir.singleNumbers" do
		assert Letcodir.singleNumbers([4,1,4,6]) == [1,6] || Letcodir.singleNumbers([4,1,4,6]) == [6,1]
		assert Letcodir.singleNumbers([1,2,10,4,1,4,3,3]) |> (fn(num) -> [[2,10],[10,2]] |> Enum.find(fn item -> item==num end) end).() != nil
		assert Letcodir.singleNumbers([9,5,4,9,3,4,5,7]) |> (fn(num) -> [[3,7],[7,3]] |> Enum.find(fn item -> item==num end) end).() != nil
	end

	test "Letcodir.findInMountainArray" do
		assert Letcodir.findInMountainArray([1,2,3,4,5,3,1],3) == 2
		assert Letcodir.findInMountainArray([0,1,2,4,2,1],3) == -1
		assert Letcodir.findInMountainArray([0,9,16,24,36,32,15,2],9) == 1
		assert Letcodir.findInMountainArray([0,9,16,24,36,32,15,2],2) == 7
	end

	test "Letcodir.isHappy" do
		assert Letcodir.isHappy(1221) == true
		assert Letcodir.isHappy(19) == true
		assert Letcodir.isHappy(65) == false
		assert Letcodir.isHappy(4335) == false
		assert Letcodir.API.pow(9,2) == 81
		assert Letcodir.API.pow(2,10) == 1024
		assert Letcodir.API.pow(2,1000) == 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
	end

	test "Letcodir.mergeTwoLists" do
		assert Letcodir.mergeTwoLists(%Letcodir.API.Node{val: 1,next: %Letcodir.API.Node{val: 2,next: %Letcodir.API.Node{val: 4,next: nil}}},%Letcodir.API.Node{val: 1,next: %Letcodir.API.Node{val: 3,next: %Letcodir.API.Node{val: 4,next: nil}}}) == %Letcodir.API.Node{val: 1,next: %Letcodir.API.Node{val: 1,next: %Letcodir.API.Node{val: 2,next: %Letcodir.API.Node{val: 3,next: %Letcodir.API.Node{val: 4,next: %Letcodir.API.Node{val: 4,next: nil}}}}}}
	end

	test "Letcodir.isSymmetric" do
		assert Letcodir.isSymmetric(Letcodir.API.TreeNode.new(1,Letcodir.API.TreeNode.new(2,Letcodir.API.TreeNode.new(3),Letcodir.API.TreeNode.new(4)),Letcodir.API.TreeNode.new(2,Letcodir.API.TreeNode.new(4),Letcodir.API.TreeNode.new(3)))) == true
		assert Letcodir.isSymmetric(
			Letcodir.API.TreeNode.new(
				1,
				Letcodir.API.TreeNode.new(
					2,
					Letcodir.API.TreeNode.new(),
					Letcodir.API.TreeNode.new(3)
				),
				Letcodir.API.TreeNode.new(
					2,
					Letcodir.API.TreeNode.new(),
					Letcodir.API.TreeNode.new(3)
				)
			)
		) == false
	end
end
